package net.simflow.swf.analyzer.chart;

import java.util.HashSet;
import java.util.TreeMap;

import net.simflow.swf.analyzer.bgnetwork.data.BGNode;
import net.simflow.swf.analyzer.bgnetwork.stats.data.BGNetworkStats;
import net.simflow.swf.analyzer.data.DataPkg;

import org.eclipse.swt.widgets.Display;

public class BGNetworkStatsChart {
	private static BGNetworkStatsChart instance = new BGNetworkStatsChart();

	private BGNetworkStatsChart() {
	}

	public static BGNetworkStatsChart getInstance() {
		return instance;
	}

	public void create(String style, Display display, String title,
			String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {
		try {
			title = title + ": " + style;
			switch (style) {
			case BGNetworkStats.NETWORK_SERVICE_DEGREE:
				this.createDegreeDistributionChart(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg.getNetworkPkg()
								.getBgNetworkStats()
								.getNetworkServiceDegreeDistribution());
				break;
			case BGNetworkStats.NETWORK_FLOW_DEGREE:
				this.createDegreeDistributionChart(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg.getNetworkPkg()
								.getBgNetworkStats()
								.getNetworkFlowDegreeDistribution());
				break;
			}
		} catch (Exception ee) {
			return;
		}
	}

	private void createDegreeDistributionChart(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			TreeMap<Integer, HashSet<BGNode>> dis) {
		StatsChart.getInstance().drawDistributionChart(display, title,
				xAxisTitle, yAxisTitle, dis);
	}
}
